package boot

import (
	"beesoft.ink/application/garage/router"
	"fmt"
	"github.com/labstack/echo/v4"
	"github.com/spf13/viper"
)

func Init() {
	LoadConfig()

	e := echo.New()

	router.Middleware(e)
	router.Init(e)

	e.Logger.Fatal(e.Start(viper.GetString("server.address")))
}
func LoadConfig() {
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath("config")

	if err := viper.ReadInConfig(); err != nil {
		panic(fmt.Errorf("fatal error config file: %w", err))
	}
}
